package com.netcracker.lab1.main;

import com.netcracker.lab1.controller.MusicTrackController;
import com.netcracker.lab1.model.MusicTrack;
import com.netcracker.lab1.socket.Server;
import com.netcracker.lab1.utils.SortComparator;
import com.netcracker.lab1.view.ConsoleView;
import com.netcracker.lab1.view.SwingView;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: nocturne
 * Date: 29.12.12
 * Time: 23:30
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    public static void main(String[] args) {

        MusicTrackController mtc = new MusicTrackController();

        Integer[] id = {0,1,2,3};
        String[] title = {"Splitting The Atom", "Pray For Rain", "Bulletproof Love", "Psyche"};
        String[] author = {"Massive Attack", "Massive Attack", "Massive Attack", "Massive Attack"};
        String[] album = {"Heligoland", "Heligoland", "Heligoland", "Heligoland"};
        Integer[] genre = {0, 0, 0, 0};
        int[] duration = {334296, 335833, 226353, 240710};

        // добавляются данные в модель
        for(int i = 0; i < 4; i++) {
            mtc.createMusicTrack(id[i], title[i], author[i], album[i], genre[i], duration[i]);
        }

        // добавить музыкальный трек в модель
        mtc.createMusicTrack(new Integer(4), "Flying High Again", "Azzy Osbourne", "Greatest Hits", 1, 256130);
        mtc.createMusicTrack(new Integer(5), "Warp", "The Upbeats", "Nobodys Out There", 2, 192339);

        mtc.createMusicTrack(new Integer(6), "Girl I Love You", "Massive Attack", "Heligoland", 0, 192339);
        mtc.createMusicTrack(new Integer(7), "Psyche", "Massive Attack", "Heligoland", 0, 132339);
        mtc.createMusicTrack(new Integer(8), "Flat of the Blade", "Massive Attack", "Heligoland", 0, 492339);
        mtc.createMusicTrack(new Integer(9), "Paradise Circus", "Massive Attack", "Heligoland", 0, 193439);
        mtc.createMusicTrack(new Integer(10), "Rush Minute", "Massive Attack", "Heligoland", 0, 142339);
        mtc.createMusicTrack(new Integer(11), "Saturday Come Slow", "Massive Attack", "Heligoland", 0, 122339);
        mtc.createMusicTrack(new Integer(12), "Atlas Air", "Massive Attack", "Heligoland", 0, 162339);



        // загрузить и востановить модель с компьютера
/*        ModelMusicTrack modelMusicTrack = null;
        try {
            modelMusicTrack = MusicTrack.openMusicTrack("c://trackLibraryNetcracker.out");
        } catch (IOException e) {
            System.out.println("Error " + e);
        } catch (ClassNotFoundException e) {
            System.out.println("Error " + e);
        }*/


        // удалить трек из библиотеки по id
        //mtc.deleteTrackInLibraryById(new Integer(2));


/*        genreManager.createGenre(new Integer(0),"Trip-hop");
        genreManager.createGenre(new Integer(1), "House");
        genreManager.createGenre(new Integer(2), "Drum and Base");
        System.out.println("Всего жанров: " + genreManager.getSizeGenres());
        System.out.println(genreManager.findGenreName(0).getGenreName());
        System.out.println(genreManager.findGenreName(1).getGenreName());*/


        // сохранить модель на компьютер
/*        try {
            BehaviorMusicTrack.saveMusicTrack("c://trackLibraryNetcracker.out");
        } catch (IOException e) {
            System.out.println("Error " + e);
        }*/


/*        ConsoleView consoleView = new ConsoleView();
        consoleView.showAllTrack();
        consoleView.showTrackById(4);

        System.out.println("- - - - C - O - M - P - A - R - A - T - O - R - - - - ");

        MusicTrack[] amt = new MusicTrack[mtc.getSizeLibrary()];
        amt[0] = mtc.findTrackById(0);
        amt[1] = mtc.findTrackById(1);
        amt[2] = mtc.findTrackById(2);
        amt[3] = mtc.findTrackById(3);
        amt[4] = mtc.findTrackById(4);
        amt[5] = mtc.findTrackById(5);


        Arrays.sort(amt, new SortComparator());

        for(int i = 0; i < mtc.getSizeLibrary(); i++){
            System.out.println(amt[i].getAuthor());
        }*/





        //SwingView swingView = new SwingView();

        Server server = new Server(1234);
        try {
            server.start();
        } catch (IOException e) {
            System.out.println(e);
        } catch (ClassNotFoundException e) {
            System.out.println(e);
        }


    }

}
